
package com.amado.course38zipInputStream;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class ZipInputStreamTest {
    private static void addLicense(Writer writer, String license) throws IOException {
        writer.write("\n");
        writer.write("yb-license: ");
        writer.write(license);
    }
    public static void main(String[] args) {
        try {
            File file = new File("C:\\Users\\Administrator\\Desktop\\temp3\\iebm-platform-server-package.zip");
            File destFile = new File("C:\\Users\\Administrator\\Desktop\\temp3\\");
            //解压zip
            ZipUtil.unzip(file,destFile);
            //修改zip
            String tempdir = System.getProperty("java.io.tmpdir");
            String tempProjcetName = getFileName(file.getName());
            String filePath = destFile+File.separator+tempProjcetName+File.separator+"config"+File.separator+"application.yml";
            System.out.println(filePath);
            Writer writer = new FileWriter(new File(filePath),true);
            addLicense(writer,"123123123123");
            writer.close();

            ZipUtil.zipDirectory(destFile+File.separator+tempProjcetName,"C:\\Users\\Administrator\\Desktop\\temp3\\aaa.zip");
        } catch (Exception e) {
            e.printStackTrace();
        }
//        ZipUtil.unZip(fileBase,"C:\\Users\\Administrator\\Desktop\\temp3");

    }
    public static String getFileName(String fileName){
        int index = fileName.lastIndexOf("-");
        return fileName.substring(0,index);
    }

}